package com.akk.platform.oem.business;

import com.akk.exception.RestBusinessException;
import com.akk.module.admin.entity.Admin;
import com.akk.module.app.entity.App;
import com.akk.module.app.service.AppService;
import com.akk.utils.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class OemAppBusiness {

    @Autowired
    AppService appService;

    public RestResponse appInfo(Admin admin) {
        return RestResponse.build(appService.findByAppId(admin.getAppId()));
    }

    public RestResponse appUpdate(App app, Admin loginAdmin) {
        if(!app.getAppId().equals(loginAdmin.getAppId()))
            throw new RestBusinessException("APP编号错误");

        app.setUpdateDate(new Date());
        appService.update(app);
        return RestResponse.build("信息修改成功");
    }
}
